package com.lagou.stage04;

import java.util.TreeMap;

public class BuyTicketTread extends Thread {
    private TicketStore ticketStore;

    public BuyTicketTread(TicketStore ticketStore) {
        this.ticketStore = ticketStore;
    }

    @Override
    public void run() {
        while (0 < ticketStore.getTicketNum()) {
            System.out.println("这是线程" + getName() + "正在买票。");
            ticketStore.buyTicket();
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
